﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace YJTTool.Common.Events
{
    public class BoolEvent
    {
        // 私有静态实例
        private static BoolEvent _instance;

        // 私有构造函数，防止外部直接实例化
        private BoolEvent() { }

        // 公共静态方法获取实例
        public static BoolEvent Instance
        {
            get
            {
                if (_instance == null)
                {
                    _instance = new BoolEvent();
                }
                return _instance;
            }
        }

        public delegate void BoolEventHandler(bool _isbool);

        public event BoolEventHandler OnMessageReceived;

        public void PushMessage(bool message)
        {
            OnMessageReceived?.Invoke(message); // 触发事件
        }
        public void Subscribe(BoolEventHandler handler)
        {
            OnMessageReceived += handler;
        }

        public void Unsubscribe(BoolEventHandler handler)
        {
            OnMessageReceived -= handler;
        }
    }
}
